﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QiHe
{
    public partial class AddEQ : Form
    {
        string log = null;
        int row = 0;
        string file;

        DataTable dt = new DataTable();
        DataSet DeptList;
        DataSet DeptList2;
        DataSet HSPEGNList;
        DataSet HSPEQAdminList;
        string EQflag = "";
        int photoCount = 0;

        public AddEQ()
        {
            InitializeComponent();
            MedEQ.Service1 sop = new MedEQ.Service1();
            DeptList = sop.HSP_Department_List(DataTemp.HSPID);
            DeptList2 = sop.HSP_Department_List(DataTemp.HSPID);
            comboBox2.DataSource = DeptList.Tables[0];
            comboBox2.DisplayMember = "Name";
            comboBox2.ValueMember = "ID";
            comboBox4.DataSource = DeptList2.Tables[0];
            comboBox4.DisplayMember = "Name";
            comboBox4.ValueMember = "ID";

            HSPEGNList = sop.Serv_HSP_Egn_List(DataTemp.HSPID);

            comboBox1.DataSource = HSPEGNList.Tables[0];
            comboBox1.DisplayMember = "ChineseName";
            comboBox1.ValueMember = "ID";



            HSPEQAdminList = sop.Serv_EQAdmin_List(DataTemp.HSPID);

            comboBox3.DataSource = HSPEQAdminList.Tables[0];
            comboBox3.DisplayMember = "ChineseName";
            comboBox3.ValueMember = "ID";



        }

        private void button1_Click(object sender, EventArgs e)
        {

            EQflag = Guid.NewGuid().ToString();

            MedEQ.Service1 sop = new MedEQ.Service1();
            string log = sop.AddEQ_Full( EQflag, textBox3.Text.ToString(), textBox1.Text.ToString(), textBox2.Text.ToString(),
                textBox6.Text.ToString(), textBox4.Text.ToString(), textBox5.Text.ToString(), textBox9.Text.ToString(),
                textBox7.Text.ToString(), comboBox2.SelectedValue.ToString(), DataTemp.HSPID, comboBox5.SelectedIndex.ToString(),
                textBox10.Text.ToString(), textBox16.Text.ToString(), comboBox1.SelectedValue.ToString(), "无",
                 textBox18.Text.ToString(), textBox14.Text.ToString(), "0", "0", textBox13.Text.ToString(), textBox21.Text.ToString(), textBox17.Text.ToString(), "5", comboBox4.SelectedValue.ToString(), textBox19.Text.ToString());
            if (log.Equals("1"))

                MessageBox.Show("添加成功");
            this.Dispose();


        }

        private void button6_Click(object sender, EventArgs e)
        {
            if (button5.Visible == false)
            {
                button5.Visible = true;
                textBox8.Visible = true;
            }
            else
            {
                button5.Visible = false;
                textBox8.Visible = false;
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            MedEQ.Service1 sop = new MedEQ.Service1();
            string result = sop.Serv_Add_Dept(textBox8.Text.ToString().Trim(), DataTemp.HSPID);
            if (result == "1")
            {
                MessageBox.Show("添加成功");

                MedEQ.Service1 sop3 = new MedEQ.Service1();
                DeptList = sop3.HSP_Department_List(DataTemp.HSPID);
                DeptList2 = sop3.HSP_Department_List(DataTemp.HSPID);
                comboBox2.DataSource = DeptList.Tables[0];
                comboBox2.DisplayMember = "Name";
                comboBox2.ValueMember = "ID";
                comboBox4.DataSource = DeptList2.Tables[0];
                comboBox4.DisplayMember = "Name";
                comboBox4.ValueMember = "ID";
                textBox8.Text = "";
                button5.Visible = false;
                textBox8.Visible = false;
            }
        }

        private void AddEQ_Load(object sender, EventArgs e)
        {

        }

        private void textBox3_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
